part of '../controller.dart';

class _NotificationDtoFactory {
  const _NotificationDtoFactory._internal();

  static const _instance = _NotificationDtoFactory._internal();

  factory _NotificationDtoFactory() {
    return _instance;
  }

  _NotificationDto fromJson(Map<String, dynamic> json) {
    final type = json[_kNotificationTypeKey] as String;

    if (type == _kDidChangeRenewalStatusNotificationTypeValue) {
      return _DidChangeRenewalStatusNotificationDto.fromJson(json);
    }

    if (type == _kDidFailToRenewNotificationTypeValue) {
      return _DidFailToRenewNotificationDto.fromJson(json);
    }

    if (type == _kDidRenewNotificationTypeValue) {
      return _DidRenewNotificationDto.fromJson(json);
    }

    if (type == _kExpiredNotificationTypeValue) {
      return _ExpiredNotificationDto.fromJson(json);
    }

    if (type == _kGracePeriodExpiredNotificationTypeValue) {
      return _GracePeriodExpiredNotificationDto.fromJson(json);
    }

    if (type == _kOfferRedeemedNotificationTypeValue) {
      return _OfferRedeemedNotificationDto.fromJson(json);
    }

    if (type == _kPriceIncreaseNotificationTypeValue) {
      return _PriceIncreaseNotificationDto.fromJson(json);
    }

    if (type == _kRefundNotificationTypeValue) {
      return _RefundNotificationDto.fromJson(json);
    }

    if (type == _kSubscribedNotificationTypeValue) {
      return _SubscribedNotificationDto.fromJson(json);
    }

    throw UnimplementedError();
  }
}
